package com.systemic.controller;

import com.systemic.core.ResponseResult;
import com.systemic.pojo.MindfulnessCollect;
import com.systemic.pojo.MindfulnessMedia;
import com.systemic.service.MindfulnessCollectService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName: CollectController
 * @Description:
 * @Author:
 * @CreateTime: 2024-02-02 08:52
 * @Version:
 **/
@RestController
@RequestMapping("/collect")
public class CollectController {

    @Resource
    private MindfulnessCollectService service;

    @PostMapping("/add")
    public ResponseResult<String> add(@RequestBody MindfulnessCollect mindfulnessCollect){
        int row = service.add(mindfulnessCollect);
        return row!=0 ? ResponseResult.success("新增成功") : ResponseResult.failed("新增失败");
    }

    @GetMapping("/select/{uid}")
    public ResponseResult<List<MindfulnessMedia>> select(@PathVariable("uid")Integer uid){
        List<MindfulnessMedia> mediaList = service.selectByUid(uid);
        return !mediaList.isEmpty() ? ResponseResult.success(mediaList) : ResponseResult.failed("没有内容");
    }

    @GetMapping("/delete/{id}")
    public ResponseResult<String> delete(@PathVariable("id")Integer id){
        int row = service.delete(id);
        return row!=0 ? ResponseResult.success("删除成功") : ResponseResult.failed("删除失败");
    }


}
